Repository navigation
Conversation
Motivation: System resolver configuration can use the root marker to indicate that no search suffix is configured, and some inputs prefix valid suffixes with a dot. Applying these strings verbatim can prevent the intended lookup. Repeated equivalent entries can repeat the same lookup. Modification: Normalize system and explicitly configured DNS search domains once in the resolver settings. Ignore the exact root marker, remove one leading dot from other entries and retain the first occurrence of each normalized string. Preserve empty suffixes, trailing dots and ndots. Document the behavior and add deterministic configuration tests. Result: An optional leading dot does not prevent a configured suffix from being used, and duplicate suffixes no longer expand the same candidate. Existing search order for distinct suffixes is unchanged. Tests: - JDK 17 focused ScalaTest compiler overlays (Scala 2.13.18 and 3.3.9): the three normalization assertions fail on the previous PR head and pass after the fix. Two root-marker cases and nine unchanged resolver configuration parser cases also pass on each axis. - Native scalafmt 3.11.5, scoped class-signature comparison and git diff --check passed. - Paradox 0.11.1 standalone parser accepted the changed DNS page. - Full sbt docs/paradox, validation and MiMa not run in the partial offline checkout. No DNS network tests were run. References: Refs netty/netty#18545; independently implemented in Pekko.
a9b50fa to
07a0cb9
Compare
| } | ||
| // Some resolv.conf providers use the root to indicate that there is no search suffix. | ||
| // Keep the first occurrence and preserve explicit empty suffixes and trailing dots. | ||
| configured.iterator.filterNot(_ == ".").map(_.stripPrefix(".")).distinct.toList |
There was a problem hiding this comment.
Edge case: the root marker is filtered before the leading dot is stripped, so an entry of .. gets past the filter and is then turned into .. That leaves the root marker in SearchDomains, and AsyncDnsResolver builds name.. from it, which is what this change is meant to avoid.
It is an unlikely value, but could the root marker be filtered again after the strip, e.g.
configured.iterator.filterNot(_ == ".").map(_.stripPrefix(".")).filterNot(_ == ".").distinct.toListKeeping the first filter matters, since stripping a plain . would otherwise turn it into an explicit empty entry. A test case with .. in the list would cover it.
| leading dot is removed from other search suffixes: `.example.org` is treated as `example.org`. | ||
| Identical entries after normalization are used once, in first-occurrence order. An explicitly | ||
| empty entry still adds no suffix at its position in that order. Trailing dots and `ndots` | ||
| are unchanged. |
There was a problem hiding this comment.
Nit: the comment on search-domains in actor/src/main/resources/reference.conf is not updated, so this normalization is only described here. Could a short note be added there as well (the root marker . is ignored, a leading dot is removed and duplicates are used once)? That comment is where most users will look when setting the value.
Motivation
System resolver configuration can use a root marker to indicate that no search suffix is configured. Treat that marker as no suffix, and normalize conventional dotted suffixes before building candidates.
Modification
Normalize both system and explicitly configured search domains: ignore the exact root marker, strip one leading dot from a suffix, and remove exact duplicates in first-occurrence order. Keep explicit empty entries, trailing dots and ndots behavior unchanged. Document the configuration.
Tests
Independent review and JDK 17 focused configuration and resolver-parser tests passed on Scala 2.13.18 and 3.3.9 (14/14 each). The additional leading-dot and deduplication regressions failed on the previous Draft version. Scoped format and DNS page parsing passed. These checks send no DNS traffic; full CI and documentation build have not yet been verified.
References
Netty #18545, independently implemented. Separate from #3796.